﻿Imports System.Data
Imports System.Data.Odbc
Imports WSEntidades
Imports Utilerias
Imports Npgsql
Imports MySql.Data.MySqlClient
Public Class ImpLocalFact
    Public Shared Function Build(ByVal dr As MySqlDataReader) As ImpLocalBE
        Dim tmpImpLocal As ImpLocalBE = New ImpLocalBE()
        Try
            With tmpImpLocal
                .IdImpLocal = convertDTFromDb.convertInt32(dr.Item("IdImpLocal"))
                .Impuesto = convertDTFromDb.ConvertString(dr.Item("Impuesto"))
                .Tasa = convertDTFromDb.ConvertDecimal(dr.Item("Tasa"))
                Select Case convertDTFromDb.ConvertString(dr.Item("Tipo"))
                    Case "T"
                        .Tipo = ImpLocalBE.TipoImpLocal.Traslado
                    Case "R"
                        .Tipo = ImpLocalBE.TipoImpLocal.Retencion
                End Select
                Select Case convertDTFromDb.ConvertString(dr.Item("Status"))
                    Case "A"
                        .Status = ImpLocalBE.EstatusImpLocal.Activa
                    Case "I"
                        .Status = ImpLocalBE.EstatusImpLocal.Inactiva
                    Case Else
                        .Status = ImpLocalBE.EstatusImpLocal.Inactiva
                End Select
                Select Case convertDTFromDb.ConvertString(dr.Item("AfectaIVA"))
                    Case "S"
                        .AfectaIVA = ImpLocalBE.AfectaIVAImpLocal.Si
                    Case "N"
                        .AfectaIVA = ImpLocalBE.AfectaIVAImpLocal.No
                    Case Else
                        .AfectaIVA = ImpLocalBE.AfectaIVAImpLocal.No
                End Select
            End With
            Return tmpImpLocal
        Catch ex As Exception
            Throw
        Finally
            tmpImpLocal = Nothing
        End Try
    End Function
End Class
